/**
* 程序入口，为整个应用提供基础层配置
*/
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { View, StyleSheet, ActivityIndicator } from 'react-native';
import { configureStore } from './redux/index';
import RootView from './root.js';
import SplashScreen from 'react-native-splash-screen'
export default class DMengAgentApp extends Component {

    constructor(props) {
        super(props);
        this.state = {
            store: null
        };
    }

    componentDidMount() {
        configureStore((store) => {
            global.auth = { isLogin: false }
            this.setState({ store })
        })
        SplashScreen.hide()
    }
    render() {
        return (
            <View style={styles.container}>
                {this.state.store ?
                    <Provider store={this.state.store}>
                        <RootView />
                    </Provider>
                    :
                    <View style={styles.container}>
                        <ActivityIndicator animating={true} size={'large'} />
                    </View>
                }
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center'
    }
});
